package com.eco.fanliapp.job;

import lombok.extern.slf4j.Slf4j;
import org.quartz.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;

/**
 * Job 的实例要到该执行它们的时候才会实例化出来。每次 Job 被执行，一个新的 Job 实例会被创建。
 * 其中暗含的意思就是你的 Job 不必担心线程安全性，因为同一时刻仅有一个线程去执行给定 Job 类的实例，甚至是并发执行同一 Job 也是如此。
 */
@Slf4j
public class ChickenJob implements  Job,Serializable {
    
	private static final Logger logger = LoggerFactory.getLogger(ChickenJob.class);
	private static final long serialVersionUID = 1L;

	@Override
	public void execute(JobExecutionContext context) throws JobExecutionException {
		log.info("大吉大利、今晚吃鸡-01-测试集群模式-quzrtz-cluster-node-second");

		 //取得job详情
         JobDetail jobDetail = context.getJobDetail();     
         // 取得job名称  
         String jobName = jobDetail.getClass().getName();  
//         logger.info("Name: " + jobDetail.getClass().getSimpleName()+"quzrtz-cluster-node-second");
//         //取得job的类
//         logger.info("Job Class: " + jobDetail.getJobClass()+"quzrtz-cluster-node-second");
//         //取得job开始时间
//         logger.info(jobName + " fired at " + context.getFireTime()+"quzrtz-cluster-node-second");
//         //取得job下次触发时间
//         logger.info("Next fire time " + context.getNextFireTime()+"quzrtz-cluster-node-second");
         
         JobDataMap dataMap =  jobDetail.getJobDataMap();
         
//         logger.info("itstyle: " + dataMap.getString("itstyle")+"quzrtz-cluster-node-second");
//         logger.info("blog: " + dataMap.getString("blog")+"quzrtz-cluster-node-second");
         String[] array = (String[]) dataMap.get("data");
         for(String str:array){
        	 logger.info("data: " + str);
         }
         
	}
}
